var mapId = 401100100;
var item = Array(1102450);
var yp = Array(1);

function init() {}

function setup(b, a) {
    em.setProperty("state", "1");
    em.setProperty("leader", "true");
    var b = em.newInstance("Vergamot" + a);
    b.setProperty("vergamotSummoned", "0");
    var d = b.setInstanceMap(mapId);
    d.resetFully();
    var c = em.getMonster(9300306);
    c.setOverrideStats();
    c.getChangedStats().hp = Math.random() * 4999999999;
    c.heal();
    d.spawnMonsterOnGroundBelow(c, new java.awt.Point(160, 182));
    b.startEventTimer(72000000);
    return b
}

function onPlayerRegistered(b, a) {
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0))
}

function onPlayerRevived(b, a) {
    return false
}

function onTimeOut(a) {
    end(a)
}

function onMapChanged(c, b, a) {
    if (a != 401100100) {
        c.unregisterPlayer(b);
        if (c.disposeIfPlayerBelow(0, 0)) {
            em.setProperty("state", "0");
            em.setProperty("leader", "true")
        }
    }
}

function onPlayerDisconnected(b, a) {
    return 0
}

function onMonsterKilled(k, b) {
    var l = em.getInstances().iterator();
    while (l.hasNext()) {
        var k = l.next();
        var d = k.getPlayers().iterator();
        while (d.hasNext()) {
            var e = d.next();
            var a = k.getMapInstance(mapId);
            var c = Math.floor(Math.random() * item.length);
            var h = Math.floor(Math.random() * yp.length);
            var g = new Packages.client.inventory.Item(4002002, 0, 1);
            for (var f = 0; f < yp[h]; f++) {
                a.spawnAutoDrop(4002002, e.getPosition())
            }
            var j = Math.floor((Math.random() * 2));
            var m = Math.floor((Math.random() * 20)) + 30;
            a.spawnAutoDrop(item[c], e.getPosition());
            cm.getPlayer().scheduleWarpTask(60, 910000000, 0, false)
        }
    }
    return 1
}

function playerExit(b, a) {
    b.unregisterPlayer(a);
    if (b.disposeIfPlayerBelow(0, 0)) {
        em.setProperty("state", "0");
        em.setProperty("leader", "true")
    }
}

function end(a) {
    a.disposeIfPlayerBelow(100, 910000000);
    em.setProperty("state", "0");
    em.setProperty("leader", "true")
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {};